#include "gtkcssnumbervalueprivate.h"
+#include "gtkcssenumvalueprivate.h"
#include "gtkstylepropertyprivate.h"
struct _GtkCssValue {
guint property_id,
GtkStyleContext *context)
{
+ GtkBorderStyle border_style;
+
+ /* I don't like this special case being here in this generic code path, but no idea where else to put it. */
+ switch (property_id)
+ {
+ case GTK_CSS_PROPERTY_BORDER_TOP_WIDTH:
+ border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_STYLE));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ return _gtk_css_number_value_new (0, GTK_CSS_PX);
+ break;
+ case GTK_CSS_PROPERTY_BORDER_RIGHT_WIDTH:
+ border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ return _gtk_css_number_value_new (0, GTK_CSS_PX);
+ break;
+ case GTK_CSS_PROPERTY_BORDER_BOTTOM_WIDTH:
+ border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ return _gtk_css_number_value_new (0, GTK_CSS_PX);
+ break;
+ case GTK_CSS_PROPERTY_BORDER_LEFT_WIDTH:
+ border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_LEFT_STYLE));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ return _gtk_css_number_value_new (0, GTK_CSS_PX);
+ break;
+ case GTK_CSS_PROPERTY_OUTLINE_WIDTH:
+ border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_OUTLINE_STYLE));
+ if (border_style == GTK_BORDER_STYLE_NONE || border_style == GTK_BORDER_STYLE_HIDDEN)
+ return _gtk_css_number_value_new (0, GTK_CSS_PX);
+ break;
+ default:
+ break;
+ }
+
switch (number->unit)
{
default:
GtkStyleContext *context,
GtkCssValue *specified)
{
- GtkBorderStyle border_style;
-
- /* The -1 is magic that is only true because we register the style
- * properties directly after the width properties.
- */
- border_style = _gtk_css_border_style_value_get (_gtk_style_context_peek_property (context, _gtk_css_style_property_get_id (property) - 1));
-
- if (border_style == GTK_BORDER_STYLE_NONE ||
- border_style == GTK_BORDER_STYLE_HIDDEN)
- return _gtk_css_number_value_new (0, GTK_CSS_PX);
- else
- return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
+ return _gtk_css_value_compute (specified, _gtk_css_style_property_get_id (property), context);
}
static GtkCssValue *
query_length_as_int,
assign_length_from_int,
_gtk_css_number_value_new (0.0, GTK_CSS_PX));
- /* IMPORTANT: compute_border_width() requires that the border-width
- * properties be immeditaly followed by the border-style properties
+ /* IMPORTANT: the border-width properties must come after border-style properties,
+ * they depend on them for their value computation.
*/
gtk_css_style_property_register ("border-top-style",
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,